using System;
using System.Linq;
using NUnit.Framework;
using PropertyExpression.ControllableQuery.Toolkit;

namespace ConsoleApplication1
{
    [TestFixture]
    public class QueryTest
    {
        [Test]
        public void CheckAllQueries()
        {
            QueryChecker.CheckAllQueries(
                QExecutor.ConnectionString,
                GetType().Assembly,
                (type, context) => {
                    if (typeof(Program.RedSwitch).Equals(type))
                        return typeof(Program).Assembly.GetTypes().Where(typeof(Program.RedSwitch).IsAssignableFrom)
                            .SelectMany(_ => context.GetConstructorInvocations(_));

                    throw new ApplicationException(
                        string.Format("There are no rules to create instances of '{0}' type.", type));
                },
                new DoNothingQRepository());
        }
    }
}